package com.qzsoft.zhjd.base.modules.parking.controller;

import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.base.modules.parking.dto.BaseParkingDto;
import com.qzsoft.zhjd.base.modules.parking.dto.BaseParkingReceiveDto;
import com.qzsoft.zhjd.base.modules.parking.service.BaseParkingService;
import com.qzsoft.zhjd.common.utils.ResultUtils;

/**
 * @ClassName BaseParkingController
 * @Description 停车信息控制器api/materielreceiptanalysis/countColumnDiagramapi/materielreceiptanalysis/countColumnDiagram
 * @author linhuawei
 * @since 2021-12-16
 */
@RestController
@RequestMapping("/api/baseParking")
public class BaseParkingController {

    @Autowired
    private BaseParkingService baseParkingService;
    

    /**
     * @Title page
     * @Description 获取停车数据分页列表
     * @param params 查询条件
     * @return 停车数据分页列表
     */
    @RequiresPermissions("api:baseParking:list")
    @GetMapping("page")
    public Result<IPage<BaseParkingDto>> page(@RequestParam Map<String, Object> params){
        IPage<BaseParkingDto> page = baseParkingService.page(params);
        return ResultUtils.ok(page);
    }

    /**
     * @Title receive
     * @Description 接收采集数据
     * @param baseCode 机构编码
     * @param dto    采集到的数据
     * @return 接收结果
     */
    @PostMapping("/receive/{baseCode}")
    public Result<String> receive(@PathVariable("baseCode") String baseCode, @RequestBody BaseParkingReceiveDto dto) {
        baseParkingService.save(baseCode, dto);
        return ResultUtils.ok();
    }

}
